package com.example.bot_cc.socket;



import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * Created by BOT-CC on 2017/4/26.
 */

public class MyConnect extends Thread {
    public Socket socket;
    public PrintWriter out;
    public String tempip,tempport,tempcontent;

    public MyConnect(String ip, String port, String content){
        tempip = ip;
        tempport = port;
        tempcontent = content;
    }
    public void run(){
        try{
            socket = new Socket(tempip,Integer.parseInt(tempport));
            //out = new PrintWriter(socket.getOutputStream(),true);
            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter
                    (socket.getOutputStream())),true);
            out.println(tempcontent);
            System.out.println("连接成功！");
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("连接失败！");
        }
    }
}
